/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao;

import java.util.HashMap;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.spi.PersistenceUnitInfo;
import org.hibernate.jpa.HibernatePersistenceProvider;

/**
 *
 * @author ChengJiLi
 */
class H2JPAProvider {

    public H2JPAProvider() {
    }
    private static final Map PROPS1 = new HashMap();
    private static final Map PROPS2 = new HashMap();
    private static final Map PROPS3 = new HashMap();
    private static final Map PROPS4 = new HashMap();

    static {
/*        
        PROPS.put("javax.persistence.jdbc.url", "jdbc:h2:./database/clientapi_data");
        PROPS.put("javax.persistence.jdbc.user", "jili");
        PROPS.put("javax.persistence.jdbc.driver", "org.h2.Driver");
        PROPS.put("javax.persistence.jdbc.password", "jili54ch");
//        PROPS.put("hibernate.cache.provider_class", "org.hibernate.cache.NoCacheProvider");
        PROPS.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
        PROPS.put("hibernate.hbm2ddl.auto", "update");
 */       

        PROPS1.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
        PROPS1.put("hibernate.connection.driver_class", "org.h2.Driver");
        PROPS1.put("hibernate.connection.url", "jdbc:h2:./data/clientapi_data");
        PROPS1.put("hibernate.connection.username", "jili");
        PROPS1.put("hibernate.connection.password", "jili54ch");
        PROPS1.put("hibernate.hbm2ddl.auto", "update");
        
        PROPS2.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
        PROPS2.put("hibernate.connection.driver_class", "org.h2.Driver");
        PROPS2.put("hibernate.connection.url", "jdbc:h2:./data/clientapi_data");
        PROPS2.put("hibernate.connection.username", "jili");
        PROPS2.put("hibernate.connection.password", "jili54ch");
        PROPS2.put("hibernate.hbm2ddl.auto", "update");
        
        PROPS3.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
        PROPS3.put("hibernate.connection.driver_class", "org.h2.Driver");
        PROPS3.put("hibernate.connection.url", "jdbc:h2:./data/clientapi_data");
        PROPS3.put("hibernate.connection.username", "jili");
        PROPS3.put("hibernate.connection.password", "jili54ch");
        PROPS3.put("hibernate.hbm2ddl.auto", "update");
        
        PROPS4.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
        PROPS4.put("hibernate.connection.driver_class", "org.h2.Driver");
        PROPS4.put("hibernate.connection.url", "jdbc:h2:./data/clientapi_data");
        PROPS4.put("hibernate.connection.username", "jili");
        PROPS4.put("hibernate.connection.password", "jili54ch");
        PROPS4.put("hibernate.hbm2ddl.auto", "update");

        //    PersistenceUnitInfo
    }
    private static EntityManagerFactory factory;

    public static EntityManagerFactory getFactory() {
        if (factory == null) {
            factory = Persistence.createEntityManagerFactory("clientapi_data", PROPS1);
        }
        return factory;
    }
}
